﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DOTNETGROUP.Data;
using DOTNETGROUP.Entities;
using System.Data;

public partial class Controls_ControlWebsiteDaThucHien : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind_Data();
        }
    }
    protected void Bind_Data()
    {
        int ToTalRows = 0;
        int ToTalRows1 = 0;
        int ToTalRows2 = 0;


        string strHTML = "";
        TList<LoaiMauWeb> Tlist_LoaiMauWeb = DataRepository.LoaiMauWebProvider.GetPaged("TrangThai = 1", "Id DESC", 0, 0, out ToTalRows);
        if (Tlist_LoaiMauWeb.Count > 0)
            for (int i = 0; i < Tlist_LoaiMauWeb.Count; i++)
            {
                TList<MauWeb> Tlist_MauWeb = DataRepository.MauWebProvider.GetPaged("IdLoaiMauWeb = " + Tlist_LoaiMauWeb[i].Id, "NgayCapNhat DESC", 0, 3, out ToTalRows2);
                if (Tlist_MauWeb.Count > 0)
                {
                    strHTML += "<div class=\"sub-wdth\">";
                    for (int k = 0; k < Tlist_MauWeb.Count; k++)
                    {
                        //string[] arrayStr = Tlist_MauWeb[k].TieuDe.Split(new string[] { "<br />" },
                        //                                   StringSplitOptions.RemoveEmptyEntries);
                        strHTML += "<div class=\"webdathuchien\">";
                        strHTML += "<a href='MauWeb/" + GetTieuDe(Tlist_MauWeb[k].TieuDe) + "_" + Tlist_MauWeb[k].Id + ".aspx'><p style=\"font-weight: normal;\">";
                        strHTML += "<img src='Upload/MauWeb/Thumb/" + Tlist_MauWeb[k].AnhDaiDien + "' width='190px' height='170px' style=\"border: 1px solid #efefef\" alt='" + Tlist_MauWeb[k].TieuDe + "'/>";
                        strHTML += "<p style=\"font-size: 13px; margin-top: 5px;\">" + Tlist_MauWeb[k].TieuDe + "</p><span>";
                        strHTML += "</a>";
                        strHTML += "</div>";
                        //strHTML += "<p>";
                    }
                    strHTML += "</div>";
                }
            }
        litMauWeb.Text = strHTML;
    }
    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
    public string formatString(string str, int n)
    {
        string kq = "";

        if (str.Length > n)
            kq = str.Substring(0, n + 1) + "...";
        else
            kq = str;

        return kq;
    }
}